/*
 * Routines for tx/rx packets through linux interfaces
 */

#ifndef _ETH_H_
#define _ETH_H_

#include <arpa/inet.h>
#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <net/ethernet.h>
#include <netpacket/packet.h>    
#include <netinet/ip.h>
#include <netinet/in.h>
#include <netinet/ip_icmp.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <netinet/in.h> 
#include <sys/types.h>  
#include <sys/socket.h> 
#include <sys/time.h>    
#include <sys/stat.h>   
#include <sys/wait.h>
#include <sys/un.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>

#define IP  in_addr_t
#define IF  interface
#define IN  struct in_addr
#define SA  struct sockaddr_ll
#define SSA struct sockaddr

#define IP_HDR_LEN     20      
#define ETH_HDR_LEN    14
#define ETH_MAC_LEN    6
#define ETH_BUF_LEN    40


typedef struct interface_t {
    char *name;
    int   index;
    char  mac[6];
    int   sock; 
    SA    sockaddr;
} IF;


IF   *eth_interface_init(char *ifname, int bind);
int   eth_packet_send(void *data, int len, IF *intf);
int   eth_packet_recv(void *data, int len, IF *intf);
int   eth_packet_parse_ip(void *data, int len, struct ip *iphdr);
void *eth_ip_packet(char *smac, char *dmac, IP *sip, IP *dip, int proto);
char *macaddr2str(char *mac);


#endif /* _ETHERNET_H_ */

